package com.ctgu.project03.controller;

import com.ctgu.project03.request.LoginVO;
import com.ctgu.project03.service.UsersService;
import com.ctgu.project03.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserController
 * @Author Alex2
 * @Date 2025/2/25 10:35
 **/
@RestController
@RequestMapping("/api/users")
public class UserController {

    @Autowired
    private UsersService userService;

    /**
     * @Author: Alex
     * @Description: 发送验证码 - redis - 单层拦截器
     */
    @PostMapping("/redis/double/code")
    public ApiResult sendCodeSingleRedis(@RequestParam(value = "phone") String phone) {
        return userService.sendCodeSingleRedis(phone);
    }

    /**
     * @Author: Alex
     * @Description: 验证登录 - redis - 单层拦截器
     */
    @PostMapping("/redis/double/login")
    public ApiResult loginSingleRedis(@RequestBody LoginVO loginVO) {
        return userService.loginSingleRedis(loginVO);
    }

    /**
     * @Author: Alex
     * @Description: 获取用户，用来被拦截
     */
    @GetMapping("/get")
    public ApiResult getAllUsers() {
        return userService.getAllUser();
    }
}